<% navigation_links = Rails.cache.fetch("navigation_links-#{user_signed_in?}-#{RequestStore.store[:subforem_id]}", expires_in: 15.minutes) do
{
    default_nav_ids: NavigationLink.from_subforem.default_section.ordered.ids,
    other_nav_ids: NavigationLink.from_subforem.other_section.ordered.ids,
  }
end %>

<nav class="mb-4 <% unless user_signed_in? %>mt-4<% end %>" data-testid="main-nav" aria-label="<%= community_name %>">
  <ul class="default-navigation-links sidebar-navigation-links spec-sidebar-navigation-links">
    <%= render partial: "layouts/sidebar_nav_link", collection: NavigationLink.where(id: navigation_links[:default_nav_ids]).ordered, as: :link %>
  </ul>
</nav>

<%# Reading Note: There's a faulty assumption that all "other_nav_links" are
    visible based on the current state (see
    ApplicationHelper#display_navigation_link? for details).  %>
<% if navigation_links[:other_nav_ids].any? %>
  <nav class="mb-4" data-testid="other-nav" aria-labelledby="other-nav-heading-<%= context %>">
    <h2 id="other-nav-heading-<%= context %>" class="crayons-subtitle-3 py-2 pl-3">
      <%= t("views.main.nav.other") %>
    </h2>
    <ul class="other-navigation-links sidebar-navigation-links spec-sidebar-navigation-links">
      <%= render partial: "layouts/sidebar_nav_link", collection: NavigationLink.where(id: navigation_links[:other_nav_ids]).ordered, as: :link %>
    </ul>
  </nav>
<% end %>

<div class="mb-4">
  <%= render partial: "layouts/social_media" %>
</div>
